<meta charset="utf-8">
<title>平台广告</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="description" content="网站描述">
<meta name="keywords" content="">
<meta name="author" content="wangl">
<link rel="icon" href="http://ow9lg82yy.bkt.clouddn.com/24f5c360-485d-4a6d-9468-2a61c353cf37.ico">
<link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all">
<link rel="stylesheet" href="/static/css/user.css" media="all">
<link rel="stylesheet" href="/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/tools.js"></script>
<script type="text/javascript" src="/static/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/static/js/CodeConst.js"></script>
<script type="text/javascript" src="/static/js/common.js"></script>
<style>
    * {
        margin: 0;
        padding: 0;
    }

    #ele {
        padding: 20px
    }

    .clearfix::after {
        content: ".";
        clear: both;
        display: block;
        overflow: hidden;
        font-size: 0;
        height: 0;
    }

    .clearfix {
        zoom: 1;
    }

    .Pagination ul {
        list-style: none;
    }

    .Pagination .total_num, .first_page, .prepage, .list_box, .nextpage, .last_page, .total_page, input, .redir {
        float: left;
    }

    .Pagination ul li {
        float: left;
        background-color: #ccc;
        border-radius: 5px;
        text-align: center;
        line-height: 22px;
        width: 22px;
        height: 22px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination ul li:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .total_num {
        margin: 0 5px;
    }

    .Pagination .total_num i {
        font-style: normal;
    }

    .Pagination .list_box {
        width: 320px;
        overflow: hidden;
        position: relative;
        height: 32px;
    }

    .Pagination .list_box ul {
        position: absolute;
        top: 0;
        left: 0;
    }

    .Pagination .prepage {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .prepage:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .nextpage {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .nextpage:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .first_page {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .first_page:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .last_page {
        background-color: #ccc;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 12px;
        margin: 0 5px;
        cursor: pointer;
        color: #8b8b8b
    }

    .Pagination .last_page:hover {
        background-color: #58acf4;
        color: #fff;
    }

    .Pagination .redir {
        background-color: #58acf4;
        color: #fff;
        border-radius: 5px;
        padding: 3px 10px;
        font-size: 14px;
        cursor: pointer;
    }

    .Pagination .redir:hover {
        opacity: 0.8;
    }

    .Pagination input {
        width: 50px;
        height: 25px;
        border-radius: 5px;
        border: 1px solid #ccc;
        outline: none;
        text-indent: 5px;
        margin: 0 5px;
    }

    .Pagination .short {
        background-color: #fff;
        cursor: default;
    }

    .Pagination .short:hover {
        background-color: #fff;
        color: #8b8b8b;
    }

    .Pagination_active {
        background-color: #58acf4 !important;
        color: #fff !important;
    }

    .detail-body {
        margin: 20px 0 0;
        min-height: 306px;
        line-height: 26px;
        font-size: 16px;
        color: #333;
        word-wrap: break-word;
    }

    /* blockquote 样式 */
    blockquote {
        display: block;
        border-left: 8px solid #d0e5f2;
        padding: 5px 10px;
        margin: 10px 0;
        line-height: 1.4;
        font-size: 100%;
        background-color: #f1f1f1;
    }

    /***
    *  ztree 图标变成黄色
    */
    .ztree .line {
        line-height: 0;
        border-top: none;
        float: none;
    }

    .ztree li span.button.ico_docu {
        background-position: -110px 0;
        margin-right: 2px;
        vertical-align: top;
    }

    /* code 样式 */
    code {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        background-color: #f1f1f1;
        border-radius: 3px;
        padding: 3px 5px;
        margin: 0 3px;
    }

    pre code {
        display: block;
    }

    .layui-form-select {
        position: static;
    }
</style>

</head>
<body class="childrenBody">
<div class="layui-col-xs12">
    <fieldset class="layui-elem-field">
        <legend>广告</legend>
        <div class="layui-field-box">
            <form class="layui-form" id="searchForm">
                <#--<div class="layui-inline" style="margin-left: 15px">-->
                <#--<label>标题:</label>-->
                <#--<div class="layui-input-inline">-->
                <#--<input type="text" value="" name="s_title" placeholder="请输入标题" class="layui-input search_input">-->
                <#--</div>-->
                <#--</div>-->
                <div class="layui-inline" style="margin-left: 15px">
                    <label>名称:</label>
                    <div class="layui-input-inline">
                        <input type="text" name="s_adName" id="s_adName"
                               autocomplete="off" class="layui-input" lay-key="1">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>上架状态:</label>
                    <div class="layui-input-inline">
                        <select id="s_adState" name="s_adState" lay-filter="category">
                            <option value="0">未上架</option>
                            <option value="1">已上架</option>
                        </select>
                    </div>
                </div>

                <#--<span>-</span>-->
                <#--<div class="layui-input-inline">-->
                <#--<input type="text" name="s_endPublistTime" id="endPublistTime" lay-verify="date"-->
                <#--autocomplete="off" class="layui-input" lay-key="2">-->
                <#--</div>-->
                <#--</div>-->
                <#--<div class="layui-inline" style="margin-left: 15px">-->
                <#--<label>内容:</label>-->
                <#--<div class="layui-input-inline">-->
                <#--<input type="text" value="" name="s_content" placeholder="请输入内容"-->
                <#--class="layui-input search_input">-->
                <#--</div>-->
                <#--</div>-->
                <div class="layui-inline">
                    <button class="layui-btn" lay-submit="" lay-filter="searchForm" type="button" onclick="search()">
                        搜索
                    </button>
                </div>
                <#--<div class="layui-inline">-->
                <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                <#--</div>-->
                <div class="layui-inline">
                    <a href="addpage" class="layui-btn layui-btn-normal" data-type="addBlogArticle">添加广告</a>
                </div>
            </form>
        </div>
    </fieldset>
    <div class="layui-form users_list">

        <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
            <thead>
            <tr>
                <th data-field="adid">
                    <div class="layui-table-cell laytable-cell-1-adid"><span>编号</span></div>
                </th>
                <th data-field="picture">
                    <div class="layui-table-cell laytable-cell-1-picture"><span>权重</span></div>
                </th>
                <th data-field="picture">
                    <div class="layui-table-cell laytable-cell-1-picture"><span>名称</span></div>
                </th>
                <th data-field="picture">
                    <div class="layui-table-cell laytable-cell-1-picture"><span>图片</span></div>
                </th>
                <th data-field="picture">
                    <div class="layui-table-cell laytable-cell-1-picture"><span>链接</span></div>
                </th>
                <th data-field="link">
                    <div class="layui-table-cell laytable-cell-1-link"><span>状态</span></div>
                </th>
                <th data-field="publistTime" data-unresize="true">
                    <div class="layui-table-cell laytable-cell-1-publistTime"><span>上架时间</span></div>
                </th>
                <th data-field="9">
                    <div class="layui-table-cell laytable-cell-1-9" align="center"><span>操作</span></div>
                </th>
            </tr>
            </thead>
            <tbody id="adList">
            </tbody>
        </table>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
            <legend>显示完整功能</legend>
        </fieldset>

        <div class="box-tools pull-right">
            <ul class="pagination" id="pagination_ul">
            </ul>
        </div>

    </div>
</div>
</body>

<!-- <script type="text/javascript" src="/static/js/jquery-1.10.2.js"></script> -->
<#--<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>-->
<script>
    var category = 0;


    function del(id) {
        $.ajax({
            url: "/back/content/ad/del",
            type: "GET",
            data: {
                adId: id
            },
            success: function (data) {
                alert(data);
                location.reload()
            }
        });
    }

    layui.use(['laypage', 'layer'], function () {
        var laypage = layui.laypage
            , layer = layui.layer;
        //获取所有广告信息


        // printJson("调用ajax");
        $.ajax({
            url: "/back/content/ad/list",
            type: "GET",
            success: function (baseDto) {
                loadData(baseDto);
                baseDto = baseDto.data;
                laypage.render({
                    elem: 'pagination_ul'
                    , count: baseDto.total
                    , curr: baseDto.fristPage //获取起始页
                    , limit: 10
                    , jump: function (obj) {
                        loadPage(obj.curr);
                    }

                });
            }
        });

        function loadPage(pageNum) {
            $.get("/back/content/ad/list?pageNum=" + pageNum, function (baseDto) {
                loadData(baseDto);
            })
        }

    });

    layui.use('form', function () {
        var form = layui.form;


    });

    layui.use('searchForm', function () {
        var searchForm = layui.form;
        form.on('select(category)', function (data) {
            category = data.value;
            searchForm.render('select');
        });
    });

    function search() {
        var adName = $("#s_adName").val();
        var adState = $("#s_adState").val();
        printJson(adState);
        $.get("/back/content/ad/search?s_adName=" + adName + "&s_adState=" + adState, function (data) {
            loadData(data);
        });

    }

    function loadData(baseDto) {
        if (baseDto.code == ERROR)
            console.log(baseDto.msg);
        else {
            //数据
            var data = baseDto.data.list;
            var text = "";

            $.each(data, function (index, ad) {
                var operation = "";
                printJson(typeof (ad.adState));
                if (ad.adStateType == 1) {
                    operation = "    <a href='/back/content/ad/launch?adId=" + ad.id + "'    type=\"button\" class=\"layui-btn layui-btn-xs\">上架</a>\n";
                } else {
                    operation = "    <a href='/back/content/ad/stop?adId=" + ad.id + "'    type=\"button\" class=\"layui-btn layui-btn-xs\">下架</a>\n";
                }
                text += "<tr>\n" +
                    "<td>" + ad.id + "</td>\n" +
                    "<td>" + ad.adWeight + "</td>\n" +
                    "<td>" + ad.adName + "</td>\n" +
                    "<td><img src=\"" + ad.adPictureUrl + "\" /></td>\n" +
                    "<td>" + ad.adLink + "</td>\n" +
                    "<td>" + (ad.adState == 1 ? '已上架' : '未上架') + "</td>\n" +
                    "<td>" + ad.startTime + " - " + ad.endTime + "</td>\n" +
                    "<td class=\"text-center\" align=\"center\">\n" +
                    operation +
                    "    <a href='/back/content/ad/editpage?adId=" + ad.id + "' onclick='setCommonParam(" + ad.id + ")'   type=\"button\" class=\"layui-btn layui-btn-xs\">编辑</a>\n" +
                    "    <button onclick ='del(" + ad.id + ")'   type=\"button\" class=\"layui-btn layui-btn-xs\">删除</button>\n" +
                    "</td>\n" +
                    "</tr>";
            });
            var adListDom = $("#adList");
            adListDom.empty();//清空子元素
            adListDom.append($(text));
        }
    }
</script>


</html>